/*
 *
 * Power.c
 *
 *  Created on: 08.02.2010
 *      Author: null
 */
#include <avr32/io.h>
#include "intc.h"

void Power66Mhz(void){
	AVR32_PM.oscctrl0 = (AVR32_PM_OSCCTRL0_STARTUP_2048_RCOSC << AVR32_PM_OSCCTRL0_STARTUP_OFFSET) | 7;
	AVR32_PM.mcctrl = 4;
    while (!(AVR32_PM.poscsr&AVR32_PM_POSCSR_OSC0RDY_MASK));
    AVR32_PM.mcctrl = 5;
    AVR32_FLASHC.fcr |= AVR32_FLASHC_FWS_MASK;

    AVR32_PM.pll[0] = AVR32_PM_PLL0_PLLEN_MASK |
    		         7 << AVR32_PM_PLL0_PLLOPT_OFFSET |
    		         7 << AVR32_PM_PLL0_PLLMUL_OFFSET |
    		         1 << AVR32_PM_PLL0_PLLDIV_OFFSET |
    		         0 << AVR32_PM_PLL0_PLLCOUNT_OFFSET;
    while (!(AVR32_PM.poscsr&AVR32_PM_POSCSR_LOCK0_MASK));
	AVR32_PM.mcctrl = 6;
}

